package com.heima.wemedia.config;

import com.aliyun.green20220302.Client;
import com.aliyun.teaopenapi.models.Config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 阿里云内容审核配置类
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "aliyun.green")
public class AliYunGreenConfig {

    private String accessKeyId;
    private String accessKeySecret;
    private String regionId;
    private String endpoint;
    private Integer readTimeout;
    private Integer connectTimeout;
    private String textService; //文本审核服务
    private String imageService; //图片审核服务

    @Bean
    public Client greenClient() throws Exception {
        Config config = new Config();
        config.setAccessKeyId(accessKeyId);
        config.setAccessKeySecret(accessKeySecret);
        config.setRegionId(regionId);
        config.setEndpoint(endpoint);
        config.setReadTimeout(readTimeout); //读取时超时时间，单位毫秒（ms）。
        config.setConnectTimeout(connectTimeout); //连接时超时时间，单位毫秒（ms）。
        return new Client(config);
    }

}
